<template>
  <div style="font-size: 12px; line-height: 60px; display: flex">
    <div style="flex: 1;">
      <span :class="collapseBtnClass" style="cursor: pointer; font-size: 18px" @click="collapse"></span>
      <el-breadcrumb separator="/" style="display: inline-block; margin-left: 10px">
        <el-breadcrumb-item :to="{path: '/manage'}">首页</el-breadcrumb-item>
        <el-breadcrumb-item><b>{{ this.$route.name }}</b></el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <el-dropdown style="width: auto; cursor: pointer;">
      <div style="display: inline-block;">
          <img :src="user.avatarUrl" alt=""
               style="width: 35px; border-radius: 50%; position: relative; top: 10px; right: 5px"/>
        <span> {{ user.username }}</span><i class="el-icon-arrow-down" style="margin-left: 5px"></i>
      </div>
      <el-dropdown-menu slot="dropdown" style="width: 100px; text-align: center">
        <el-dropdown-item style="font-size: 14px; padding: 5px 0px"><span @click="toPersonInfo">上传头像</span></el-dropdown-item>
        <el-dropdown-item style="font-size: 14px; padding: 5px 0px"><span @click="exit">退出</span></el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  name: "Header",
  props: ['collapseBtnClass', 'collapse'],
  data() {
    return {
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {}
    }
  },
  methods: {
    toPersonInfo() {
      this.$router.push("/manage/person")
    },
    exit() {
      localStorage.removeItem("user")
      this.$router.push("/")
      this.$message.success("退出成功")
    }
  }
}
</script>

<style scoped>

</style>